package org.amphiprion.descenttool.util;

import java.util.HashMap;
import java.util.Map;

import org.amphiprion.descenttool.view.EncounterView;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class BitmapUtil {
	private static Map<String, Bitmap> bitmaps = new HashMap<String, Bitmap>();
	private static String path = "/images/";

	public static Bitmap getBitmap(String name) {
		Bitmap b = bitmaps.get(name);
		if (b == null) {
			b = BitmapFactory.decodeStream(EncounterView.class.getResourceAsStream(path + name));
			bitmaps.put(name, b);
		}
		return b;
	}

	public static void clearCache() {
		bitmaps.clear();
	}
}
